package com.go8.admin.goods.controller;

import com.go8.common.service.ServiceResponse;
import com.go8.goods.service.ProductService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/task")
public class TaskController {
    private final Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private ProductService productService;

    @PostMapping("/sync/goods")
    public Object syncGoods(){
        try {
            productService.syncAll();
            return ServiceResponse.ok();
        } catch (Exception e) {
            logger.error(e.getMessage());
            return ServiceResponse.error();
        }
    }
}
